/**
* 渲染表格操作
* @2018年3月19日08:54:13
* @since 2.1
* @version 2.1
* @returns
*/
$(function(){
	
  var reimburseId;

  //表格参数
  var data = {
		url:path+'/financial/reimburse',
		columns: [{field:'checked',checkbox:true},{field:'reimburseNumber',title:'报销单号'},{field:'reimburseId',visible:false},{field:'reimburseDate',title:'报销日期'},{field:'reimburseApplicant',title:'申请人'},{field:'reimburseApprover',title:'审批人'},{field:'reimburseTotalMoney',title:'总报销额'},{field:'reimburseStatus',title:'状态',formatter:function(value,row,index){switch(value){case"等待审核":return'<span class="layui-badge layui-bg-orange">等待审核</span>';case"审核中":return'<span class="layui-badge-rim">审核中</span>';case"审核通过":return'<span class="layui-badge layui-bg-green">审核通过</span>';case"审核不通过":return'<span class="layui-badge">审核不通过</span>';default:return'<span class="layui-badge layui-bg-orange">非法篡改数据!</span>';}}},{field: 'reimburseReceiptPath',title: '报销单据预览',formatter: function (value, row, index) {return "<button class='layui-btn layui-btn-primary' onclick=queryReceipt('"+row.reimburseId+"')>查看报销单据</button>";}},{field:'reimburseRemark',title:'备注'}],	
		method: 'GET',//请求方式（*）
        contentType : "application/x-www-form-urlencoded;charset='UTF-8'", //加上这个才可以接收到值
		sortable: true,
        sortOrder: "asc",
        search: false,
        exportOptions:{  
           fileName: '报销管理'+exportDate.toLocaleString(),//文件名称设置  
           worksheetName: 'sheet1',//表格工作区名称  
           tableName: '报销管理',
           ignoreColumn: [0,1],
		   unaffectedColumn:0
        }
  }
  
  //条件搜索框参数
  var param = [{text:"审批人",name:"reimburseApprover",verify:"peopleName",type:"text"},{text:"申请人",name:"reimburseApplicant",verify:"peopleName",type:"text"},{text:"报销状态",name:"reimburseStatus",type:"select",option:[{key:"等待审核",value:"等待审核"},{key:"审核中",value:"审核中"},{key:"审核通过",value:"审核通过"},{key:"审核不通过",value:"审核不通过"}]},{text:"报销单号",name:"reimburseNumber",verify:"intNumber",type:"text"},{text:"报销日期",name:"supArchiEnterpriseName",verify:"",type:"text"}];

  renderTable(cTable,data);
  
  createQueryPanel(param);

  laydate.render({
	  elem: '[name="supArchiEnterpriseName"]'
	  ,range: true
  });

  form.render();
})

$("#remove_btn").click(function(){
	requestRemoveData("supArreId","/financial/supplier-arrears");
})

$('#add_btn').click(function(){
	openOperateWindow({
		title: "新增报销",
		url: "/admin/enterpriseManagement/financialManagement/reimburse/reimburse-add.jsp"
	})
});
 
$('#modify_btn').click(function(){
	openOperateWindow({
		title: "修改报销",
		isUpdate: true,
		url: "/admin/enterpriseManagement/financialManagement/supplierArrears/window-update.jsp"
	})
});

/*查看报销单据*/
function queryReceipt(orderNumber){
	this.reimburseId = orderNumber;
	openOperateWindow({
		title: "上传报销单",
		width: "60%",
		height: "80%",
		url: "/admin/enterpriseManagement/financialManagement/reimburse/reimburse-receipt-fileupload.jsp"
	})
}
